﻿@namespace Masa.Tsc.Web.Admin.Rcl.Components
@inherits TscComponentBase

<div class="d-flex mb-4" style="@Style">
    <SAutoComplete Placeholder="@I18n.T("Service")" Label="@I18n.T("Service")"
                   Items="_services?? new()"
                   @bind-Value="Service"
                   ItemText="item => item"
                   ItemValue="item => item"
                   TItem=string
                   TValue=string
                   TItemValue=string
                   Small
                   BackgroundColor="white"
                   Clearable
                   Flat
                   Solo
                   HideSelected=false
                   ClearIcon="mdi-close"
                   Outlined="false"
                   Loading="_serviceSearching"
                   Class="mr-4 rounded-2 m-input--h-40"
                   Style="max-width: 280px"
                   OnSelectedItemUpdate="()=>Query(isService:true)"
                   OnClearClick="()=>Query(isService:true)" />

    <SAutoComplete Placeholder="@I18n.T("Instance")" Label="@I18n.T("Instance")"
                   Items="_instances?? new()"
                   @bind-Value="_instance"
                   TItem=string
                   TValue=string
                   ItemText="item => item"
                   ItemValue="item => item"
                   TItemValue=string
                   Small
                   BackgroundColor="white"
                   Clearable
                   Flat
                   Solo
                   HideSelected=false
                   ClearIcon="mdi-close"
                   Outlined="false"
                   Loading="_instanceSearching"
                   Class="mr-4 rounded-2 m-input--h-40"
                   Style="max-width: 280px"
                   Disabled="@(string.IsNullOrWhiteSpace(Service))"
                   OnSelectedItemUpdate="()=>Query(isInstance:true)"
                   OnClearClick="()=>Query(isInstance:true)" />

    <SAutoComplete Placeholder="@I18n.T("Endpoint")" Label="@I18n.T("Endpoint")"
                   Items="_endpoints?? new()"
                   @bind-Value="_endpoint"
                   TItem=string
                   TValue=string
                   ItemText="item => item"
                   ItemValue="item => item"
                   TItemValue=string
                   OnSearchInputUpdate="@SearchEndpoints"
                   HideSelected=false
                   Small
                   BackgroundColor="white"
                   Clearable
                   Flat
                   Solo
                   ClearIcon="mdi-close"
                   Outlined="false"
                   Loading="_endpointSearching"
                   Disabled="@(string.IsNullOrWhiteSpace(Service))"
                   Class="mr-4 rounded-2 m-input--h-40"
                   Style="max-width: 280px;"
                   OnSelectedItemUpdate="()=>Query(isEndpoint:true)"
                   OnClearClick="()=>Query(isEndpoint:true)" />
    @if (!PageMode)
    {
        <MSpacer />
    }
    <SSearch BackgroundColor="white" @bind-Value="@Keyword" OnEnter="OnEnter" MaxWidth="0" Style="@_style" Class="mr-4" />
    @if (PageMode)
    {
        <SDateTimeRangeToolbar Class="my-auto"
                           OnUpdate="OnDateTimeUpdate"
                           OnAutoUpdate="OnDateTimeAutoUpdate"
                           StartDateTime="StartDateTime.ToDateTimeOffset(CurrentTimeZone)"
                           EndDateTime="EndDateTime.ToDateTimeOffset(CurrentTimeZone)"
                           ShowInterval
                           ShowQuickChange
                           ShowTimeZoneSelector />
    }
</div>